package com.example.config;

import com.example.quartz.MyQuartz;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class QuzrtzConfig {

    @Bean
    public JobDetail printJobDetail() {
        //绑定具体的工作
        //storeDurably持久存储
        return JobBuilder.newJob(MyQuartz.class).storeDurably().build();
    }

    @Bean
    public Trigger printTrigger() {
        //绑定对应的工作明细
        ScheduleBuilder schedBulder = CronScheduleBuilder.cronSchedule("0/5 * * * * ?");
        return TriggerBuilder.newTrigger().forJob(printJobDetail()).withSchedule(schedBulder).build();
    }
}
